﻿using System;
using System.Collections.Generic;
using System.Data;
using Spring.Data;
using TeamTasker.Utils;


namespace TeamTasker.Server.DataAccess.Support
{
    class IdNameRowCallback : IRowCallback
    {
        private IDictionary<long, string> storage;

        public IdNameRowCallback(IDictionary<long, string> dst)
        {
            Validate.NotNull(dst, "Data storage reference is illegal: null");
            storage = dst;
        }

        public void ProcessRow(IDataReader reader)
        {
            long id = reader.GetInt64(0);
            string name = reader.GetString(1);
            storage.Add(id, name);
        }
    }
}
